/*
 * @Author: xmily
 * @Date: 2020-10-25 23:07:30
 * @LastEditors: xmily
 * @LastEditTime: 2023-09-10 23:40:06
 * @FilePath: \glxxapi\cfg\dbconfig.js
 * @Description: 
 * 
 * Copyright (c) 2023 by xmily/mxthink.com.cn, All Rights Reserved. 
 */
var mongoose = require('mongoose');
mongoose.Promise = global.Promise;
// var dbURI='mongodb://glxx:19810921xMily@192.168.3.99:27017/glxx'
var dbURI='mongodb://127.0.0.1:27017/syxtest'

// var dbURI='mongodb://glxx:20120922_glxxtest@192.168.3.99:27017/glxxtest'

//var dbURI='mongodb+srv://fjxx:818140@xmily-kxubs.mongodb.net/fjxxv2?retryWrites=true'
    //var dbURI='mongodb://localhost:27017/fjxx'
    mongoose.connect(dbURI,{useNewUrlParser:true});
// mongoose.connect(dbURI);


mongoose.connection.on('connected', function() {
    console.log('Mongoose数据库已连接到' + dbURI);
});

mongoose.connection.on('error', function(err) {
    console.log('Mongoose连接时发发生错误:' + err);
});

mongoose.connection.on('disconnected', function() {
    console.log('Mongoose已断开连接');
});

process.on('SIGINT', function() {
    mongoose.connection.close(function() {
        console.log('应用程序终止Mongoose已经断开连接');
        process.exit(0);
    });
});

module.exports=mongoose;